package com.baidu.fastXML;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Event {

    /**
     * 事件元数据
     */
    private String eventVersion;
    private String eventId;
    private String eventType;
    private String eventSource;
    private String eventName;
    @Range(min = 1, max = 100, message = "eventTimeInMilliseconds超出限制")
    private long eventTimeInMilliseconds = System.currentTimeMillis();

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC")
    private Date eventTime = new Date(eventTimeInMilliseconds);

    /**
     * 用户信息
     */
    private UserIdentity userIdentity;
    private String userIpAddress;
    private String userAgent;

    /**
     * 定位信息
     */
    private String regionId;
    private String requestId;
    private String orderId;
    private String tag;

    /**
     * 事件详情
     */
    private String apiVersion;
    private String description;
    private String errorCode;
    private String errorMessage;
    private EventDetail eventDetail = new EventDetail();

    /**
     * 资源信息
     */
    private List<ResourceInfo> resources = new ArrayList<>();

    /**
     * 事件结果
     */
    private boolean success = true;

}
